package com.imooc.miaosha.config;

import com.google.common.collect.Maps;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

@Configuration
public class RabbitMqConfig {

    public static final String ORDER_ROUTING_KEY="order.#";
    public static final String ORDER_EXCHANGE="ORDER_EXCHANGE";
    public static final String ORDER_QUEUE="ORDER_QUEUE";
    public static final String ORDER_STATUS_QUEUE_NAME="ORDER_STATUS_QUEUE_NAME";
    public static final String ORDER_STATUS_EXCHANGE_NAME="ORDER_STATUS_QUEUE_NAME";
    public static final String ORDER_STATUS_ROUTING_KEY="orderStatus.#";
    @Bean
    public Queue orderQueue(){
        return new Queue(ORDER_QUEUE);
    }

    @Bean
    public TopicExchange orderExchange(){
        return new TopicExchange(ORDER_EXCHANGE);
    }
    @Bean
    public Binding orderBinding(){
        return BindingBuilder.bind(orderQueue()).to(orderExchange()).with(ORDER_ROUTING_KEY);
    }


    @Bean
    public Queue orderStatusQueue(){
        return new Queue(ORDER_STATUS_QUEUE_NAME);
    }
    @Bean
    public TopicExchange orderStatusExchange(){
return new TopicExchange(ORDER_STATUS_EXCHANGE_NAME);
    }
    @Bean
    public Binding orderStatusBing(){
        return BindingBuilder.bind(orderStatusQueue()).to(orderStatusExchange()).with(ORDER_STATUS_ROUTING_KEY);
    }
}
